﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Topic.aspx.cs" Inherits="Topic" ValidateRequest="false" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <div class="col-md-8 col-md-offset-2" >
        <asp:ValidationSummary ID="ValidationSummary" runat="server"
            HeaderText="An error has occured, please fix it and try again."></asp:ValidationSummary>

        <asp:LinkButton runat="server" ID="EditButton">Edit Topic</asp:LinkButton>
        <asp:LinkButton runat="server" ID="DeleteButton" OnClick="DeleteButton_Click">Delete Topic</asp:LinkButton>
        <asp:LinkButton runat="server" ID="CompleteEditButton" OnClick="CompleteEditButton_Click" Visible="false">Confirm Changes</asp:LinkButton>

        <h2 runat="server" id="noTopicH2">There is no topic to view </h2>
        <div id="topicDiv" runat="server">

            <asp:TextBox ID="HeaderTextBox" runat="server" Enabled="false"></asp:TextBox>
            <asp:TextBox ID="TopicText" runat="server" Enabled="false"></asp:TextBox>
            <asp:Label ID="AuthorLabel" runat="server" Text="Author"></asp:Label>
            <asp:Label ID="DateLabel" runat="server" Text="Date"></asp:Label>
        </div>



        <div id="CommentsDiv" runat="server">

            <asp:ListView ID="ListView1" runat="server" DataSourceID="ObjectDataSource1" DataKeyNames="CommentID" OnItemDeleted="ListView1_ItemDeleted">
                <AlternatingItemTemplate>
                    <li style="">Author:
                    <asp:Label Text='<%# Eval("Author") %>' runat="server" ID="AuthorLabel" /><br />

                        <asp:Label Text='<%# Eval("TextContent") %>' runat="server" ID="TextContentLabel" /><br />
                        Date:
                    <asp:Label Text='<%# Eval("Date") %>' runat="server" ID="DateLabel" /><br />
                        <asp:Button runat="server" CommandName="Delete" Text="Delete" ID="DeleteButton" Visible='<%#DeleteButtonVisible(Convert.ToInt32(Eval("UserID")))%>' />
                    </li>
                </AlternatingItemTemplate>
                <EmptyDataTemplate>
                    No data was returned.
                </EmptyDataTemplate>
                <ItemSeparatorTemplate>
                    <br />
                </ItemSeparatorTemplate>
                <ItemTemplate>
                    <li style="">Author:
                    <asp:Label Text='<%# Eval("Author") %>' runat="server" ID="AuthorLabel" /><br />

                        <asp:Label Text='<%# Eval("TextContent") %>' runat="server" ID="TextContentLabel" /><br />
                        Date:
                    <asp:Label Text='<%# Eval("Date") %>' runat="server" ID="DateLabel" /><br />
                        <asp:Button runat="server" CommandName="Delete" Text="Delete" ID="DeleteButton" Visible='<%#DeleteButtonVisible(Convert.ToInt32(Eval("UserID")))%>' />
                    </li>
                </ItemTemplate>
                <LayoutTemplate>
                    <ul runat="server" id="itemPlaceholderContainer" style="">
                        <li runat="server" id="itemPlaceholder" />
                    </ul>
                    <div style="">
                        <asp:DataPager runat="server" ID="DataPager1" PageSize="10">
                            <Fields>
                                <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" ShowLastPageButton="True"></asp:NextPreviousPagerField>
                            </Fields>
                        </asp:DataPager>

                    </div>
                </LayoutTemplate>
                <SelectedItemTemplate>
                    <li style="">CommentID:
                    <asp:Label Text='<%# Eval("CommentID") %>' runat="server" ID="CommentIDLabel" /><br />
                        TopicID:
                    <asp:Label Text='<%# Eval("TopicID") %>' runat="server" ID="TopicIDLabel" /><br />
                        UserID:
                    <asp:Label Text='<%# Eval("UserID") %>' runat="server" ID="UserIDLabel" /><br />
                        Author:
                    <asp:Label Text='<%# Eval("Author") %>' runat="server" ID="AuthorLabel" /><br />
                        TextContent:
                    <asp:Label Text='<%# Eval("TextContent") %>' runat="server" ID="TextContentLabel" /><br />
                        Date:
                    <asp:Label Text='<%# Eval("Date") %>' runat="server" ID="DateLabel" /><br />
                        <asp:Button runat="server" CommandName="Delete" Text="Delete" ID="DeleteButton" />
                    </li>
                </SelectedItemTemplate>
            </asp:ListView>


            <asp:ObjectDataSource runat="server" ID="ObjectDataSource1" SelectMethod="GetAllCommentsOnTopicID" TypeName="Service" DeleteMethod="DeleteCommentOnID" OnDeleting="ObjectDataSource1_Deleting">
                <DeleteParameters>
                    <asp:Parameter Name="CommentID" Type="Int32"></asp:Parameter>
                </DeleteParameters>
                <SelectParameters>
                    <asp:QueryStringParameter QueryStringField="topic" DefaultValue="0" Name="topicID" Type="Int32"></asp:QueryStringParameter>
                </SelectParameters>
            </asp:ObjectDataSource>


            <div id="commentDiv" runat="server">
                <asp:TextBox ID="CommentTextbox" runat="server"></asp:TextBox>
                <asp:LinkButton ID="CommentButton" runat="server" OnClick="CommentButton_Click">Comment</asp:LinkButton>
            </div>
        </div>
    </div>
</asp:Content>

